package project.dade.cn.bst.adapter.base;

import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import cn.bingoogolapple.androidcommon.adapter.BGARecyclerViewAdapter;
import cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper;
import project.dade.cn.bst.R;
import project.dade.cn.bst.model.ShopModel;

/**
 * Created by vain zhou on 2016/1/18.
 */
public class ShoppingAdapter extends BGARecyclerViewAdapter<ShopModel> {


    public ShoppingAdapter(RecyclerView recyclerView) {
        super(recyclerView, R.layout.adapter_newshop);
    }
    public void setItemChildListener(final BGAViewHolderHelper viewHolderHelper) {
        viewHolderHelper.setItemChildClickListener(R.id.delete);
        viewHolderHelper.setItemChildCheckedChangeListener(R.id.choose);
        viewHolderHelper.setItemChildClickListener(R.id.sub);
        viewHolderHelper.setItemChildClickListener(R.id.add);



    }



    protected void fillData(BGAViewHolderHelper helper, int postion, ShopModel shopModel) {

        ImageView avatorIv =helper.getView(R.id.itemPic);
        Glide.with(mContext).load(shopModel.getProductImage()).placeholder(R.drawable.image_loader_small).error(R.drawable.image_loader_small).into(avatorIv);
        helper.setText(R.id.itemTitle, shopModel.getProductName());
        helper.setText(R.id.sellPrice, shopModel.getPrice());
        helper.setText(R.id.itemNum, shopModel.getQuantity());
        if(shopModel.isChecked){
            helper.setChecked(R.id.choose, true);
        }else {
            helper.setChecked(R.id.choose, false);

        }
    }



}
